From dc4c7706ac5a4ad085a1cf63c19922abc997c5fc Mon Sep 17 00:00:00 2001 From: Ell Date: Thu, 14 Jun 2018 02:16:08 -0400 Subject: [PATCH] babl-palette: warn when trying to create a palette with > 256 colors ... and only use the first 256 colors. --- babl/babl-palette.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/babl/babl-palette.c b/babl/babl-palette.c index 278c854..c70d4ed 100644 --- a/babl/babl-palette.c +++ b/babl/babl-palette.c @@ -872,6 +872,16 @@ babl_palette_set_palette (const Babl *babl, { BablPalette **palptr = babl_get_user_data (babl); babl_palette_reset (babl); + + if (count > 256) + { + babl_log ("attempt to create a palette with %d colors. " + "truncating to 256 colors.", + count); + + count = 256; + } + if (count > 0) { *palptr = make_pal (format, data, count); -- 2.30.2